package com.landiao.ctrler.management;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.landiao.common.factory.ResultMsgFactory;
import com.landiao.common.utils.CodecUtils;
import com.landiao.ctrler.BaseCRUDCtrler;
import com.landiao.entities.Employee;
import com.landiao.entities.Role;
import com.landiao.entities.Shop;
import com.landiao.service.RoleService;

@Controller
@RequestMapping("/management/role")
public class RoleCtrler extends BaseCRUDCtrler<Role, String>  {
	private RoleService getRoleService() {
        return (RoleService) baseService;
    }
	@ResponseBody
	@RequestMapping("listRole")
	public List<Role> listRole(Role role){
		List<Role> list = getRoleService().getListRole(role);
		return list;
	}
	@Override
	public String save(Role t, RedirectAttributes redirectAttr) {
		// TODO Auto-generated method stub
		t.setRoleId(CodecUtils.getUUID());
		t.setCompId(this.getClientUser().getUser().getCompId());
		baseService.save(t);
		redirectAttr.addFlashAttribute("resultMsg",
				ResultMsgFactory.success("添加成功"));
		return redirectToUrl(viewName("index"));
	}
}
